const { Router } = require('express')
const {
  addArticle,
  pageArticle,
  getArticle,
  deleteArticle,
  updateArticle,
  getLatestArticles,
} = require('../controllers/articleController')
const interceptor = require('../middlewares/interceptor')
const restrictTo = require('../middlewares/restrictTo')

const router = Router()

router.post('/article', addArticle)
router.get('/article', pageArticle)
router.get('/article/latest', getLatestArticles)
router.get('/article/:id', getArticle)
router.delete('/article/:id', interceptor, restrictTo(['admin']), deleteArticle)
router.put('/article/:id', interceptor, restrictTo(['admin']), updateArticle)

module.exports = router
